function fireClick(node){
	if ( document.createEvent ) {
		var evt = document.createEvent('MouseEvents');
		evt.initEvent('click', false, true);
		node.dispatchEvent(evt);	
	} else if( document.createEventObject ) {
		node.fireEvent('onclick') ;	
	} else if (typeof node.onclick == 'function' ) {
		node.onclick();	
	}
}

function openOtherinfo(otherid, cacaocheck) {
	
//	var othertfipanel = Ext.getCmp('othertfipanel');
//	othertfipanel.setHtml(dataitem.getRecord().get('Total').split('.')[0]+'%');
	var kind = "otherinfo";
	Ext.data.JsonP.request({
		url: 'http://itscreater.cafe24.com/Triends/Counting.jsp',
		params:{
			id: otherid, 
			kind: kind
		},
		callbackKey: 'callback',
		success: function(result) {
			
		}
	})
	
	if (cacaocheck == null) {
		cacaocheck = 'cannot';
	}
	var activetab = Ext.getCmp('main').getActiveItem().id;
	var othersStore = Ext.getStore('OthersStore'+otherid);
	if (Ext.typeOf(othersStore) == 'object') {
		othersStore.removeAll();
	} else {
		othersStore = Ext.create("Ext.data.Store",{
			model: "Triends.Model.Othersinfo"
		});
		othersStore.setStoreId('OthersStore'+otherid);
	}
	
	var otherHOSTtingStore = Ext.getStore('otherHOSTtingStore'+otherid);
	if (Ext.typeOf(otherHOSTtingStore) == 'object') {
		otherHOSTtingStore.removeAll();
	} else {
		otherHOSTtingStore = Ext.create("Ext.data.Store",{
			model: "Triends.Tinglist",
			sorters: [{
				property: 'STARTDATE',
				direction: 'ASC'
			},
			{
				property: 'STARTTIME',
				direction: 'ASC'
			}]
		});
		otherHOSTtingStore.setStoreId('otherHOSTtingStore'+otherid);
	}
		    	
	
	var otherATTENDtingStore = Ext.getStore('otherATTENDtingStore'+otherid);
	if (Ext.typeOf(otherATTENDtingStore) == 'object') {
		otherATTENDtingStore.removeAll();
	} else {
		otherATTENDtingStore = Ext.create("Ext.data.Store",{
			model: "Triends.Tinglist",
			sorters: [{
				property: 'STARTDATE',
				direction: 'ASC'
			},
			{
				property: 'STARTTIME',
				direction: 'ASC'
			}]
		});
		otherATTENDtingStore.setStoreId('otherATTENDtingStore'+otherid);
	}
	
	Triends.app.getHistory().add(Ext.create('Ext.app.Action', {
        url: 'otherinfo/'+ activetab + '/' + otherid + '/' + cacaocheck
    }));
	
//	navigator.geolocation.getCurrentPosition(function(position){
//        	
//        var userlat = position.coords.latitude;
//        var userlng = position.coords.longitude;
//    	var usertheme = UserStore.getAt(0).data.UserTheme;
//    	
//        Ext.data.JsonP.request({
//    	url: 'http://itscreater.cafe24.com/Triends/Othersinfo.jsp',
//        params: {id: otherid, userlat: userlat, userlng: userlng, usertheme: usertheme},
//        callbackKey: 'callback',
//            success: function(result) {
//            	othersStore.setData(result);
//           	    Ext.data.JsonP.request({
//        			url: 'http://itscreater.cafe24.com/Triends/UserHostTing.jsp',
//        			params: {id: otherid,
//								userlat: userlat, 
//								userlng: userlng, 
//								usertheme: usertheme},
//        			callbackKey: 'callback',
//        			success: function(result) {
//            			for(i=0;i<result.length;i++){
//							var date = result[i].DATE.split(' ')[0];
//							var hour = result[i].DATE.split(' ')[1].substr(0,2);
//							var minute = result[i].DATE.split(' ')[1].substr(2);
//							var ampm;
//							if(hour >= 12){
//								hour = hour-12;
//								ampm = "PM"
//							} else{
//								ampm = "AM"
//							}
//							var finaldate = date+" "+ampm+" "+hour+""+minute;
//							result[i].AMPMDATE = finaldate; 
//						}
//						otherHOSTtingStore.setData(result);
//						
//            			Ext.data.JsonP.request({
//        					url: 'http://itscreater.cafe24.com/Triends/UserAttendTing.jsp',
//        					params: {
//        						id: otherid,
//								userlat: userlat, 
//								userlng: userlng, 
//								usertheme: usertheme
//							},
//        					callbackKey: 'callback',
//        					success: function(result) {
//        						for(i=0;i<result.length;i++){
//									var date = result[i].DATE.split(' ')[0];
//									var hour = result[i].DATE.split(' ')[1].substr(0,2);
//									var minute = result[i].DATE.split(' ')[1].substr(2);
//									var ampm;
//									if(hour >= 12){
//										hour = hour-12;
//										ampm = "PM"
//									} else{
//										ampm = "AM"
//									}
//									var finaldate = date+" "+ampm+" "+hour+""+minute;
//									result[i].AMPMDATE = finaldate;
//								}
//								otherATTENDtingStore.setData(result);
//            					
//        					}
//    					});
//        			}
//    			});
//            }
//    	});
//    });
	Ext.Viewport.setMasked(false);
}

Ext.define("Triends.Model.Othersinfo",{
	extend: "Ext.data.Model",
	config: {
		fields: [
			"ID", "Name", "Email", "Age", "Gender", "Introduction", "Cacao", "UserLat", "UserLng", "UserTheme", "Distance", "Time", "Theme", "Total", "Wifi"
		]
	}
});

Ext.define('Triends.view.Othersinfo', {
 	extend: 'Ext.Panel',
	requires: ['Triends.view.Sendmessage'],
 	id: 'othersinfo',
 	xtype: 'othersinfo',
	config: {
 		style: 'position:relative;background:white',
 		layout: 'vbox',
 		fullscreen: true,
 		scrollable: true,
 		listeners: {
 			deactivate: function(oldActiveItem, container, newActiveItem, eOpts) {
					Ext.getCmp('othersinfo').destroy();
				}
 		},
 	items: [{
 			xtype: 'panel',
 			layout: 'hbox',
	 		height: 200,
 			style: {'padding':'15px', 'border-bottom':'1px #CBCAC7 solid'},
 			items: [
 			{
 				xtype: 'panel',
 				flex: 1,
 				items:[{
 					xtype: 'panel',
 					style: 'left:50%;margin-left:-65px;padding-top:15px',
					id: 'otherimg',
					width: 130,
					height: 130
 				}]
 			},
 			{
 				xtype: 'panel',
 				flex: 1.5,
 				layout: 'vbox',
 				items:[{
 					xtype: 'dataview',
 					id: 'otherinfoview',
 					margin: 10,
 					scrollable: false,
 					itemTpl: "<div align='left'><b><font size='4'>{Name}</font></b></div>"
 				},
 				{
 					xtype: 'panel',
 					id: 'otherlocationpanel',
 					style: 'margin-left:10px;margin-top:-10px'
	 			},
	 			{
	 				xtype: 'spacer',
	 				height: 19
	 			},
 				{
 					
	 				xtype: 'panel',
	 				style: 'padding-right:10px;margin-bottom:3px',
	 				items: [{
	 					xtype: 'button',
		 				id: 'FBbutton',
	 					width: '100%',
 						iconCls: 'facebook',
 						iconMask: true,
 						style: 'border: 2px outset;margin-left:10px;',
 						ui: 'small',
 						handler: function(){
 							var el = document.getElementById('moveFB');
 							fireClick(el);
 						}
	 				}]
 				},
 				{
 					xtype: 'panel',
 					style: 'padding-right:10px',
 					items: [{
 						xtype: 'button',
 						style: 'border: 2px outset;margin-left:10px',
		 				id: 'msgboxbtn2',
		 				ui: 'small',
		 				text: 'Send Message',
		 				width: '100%',
		    		   	iconCls: 'mail',
		    	 	   	iconMask: true,
		   			   	handler: function() {
		   			   		var userid = Ext.getStore('UserStore').getAt(0).data.ID;
		   			   		var username = Ext.getStore('UserStore').getAt(0).data.Name;
		   			   		var otherid = Ext.getCmp('otherinfoview').getStore().getAt(0).getData().ID;
		   			   		var othername = Ext.getCmp('otherinfoview').getStore().getAt(0).getData().Name;
				    		var send = Ext.create('Triends.view.Sendmessage');
				    		var getterpanel = Ext.getCmp('getterpanel');
				    		getterpanel.setData({SenderID: userid, Sender: username, GetterID: otherid, Getter: othername});
				    		send.setData({SenderID: userid, Sender: username, GetterID: otherid, Getter: othername});
				    		Ext.Viewport.add(send);
            			}	
 					}]
 				}
 				]
 			}]
 		},
 		{
 			xtype: 'panel',
 			layout: 'vbox',
 			height: 100,
 			style: 'padding:15px;border-bottom:1px #CBCAC7 solid',
 			items: [{
				xtype: 'panel',
				html: "<p style='margin-left:5px'><font size='4'><b>Theme</b></font></p>"
			},
 			{
 				xtype: 'panel',
 				width: '100%',
 				items: [{
 					xtype: 'image',
		 			id: 'otherthemepanel',
		 			centered: true,
 					width: 48,
 					height: 48
 				}]
 			}]
 		},
 		{
 			xtype: 'panel',
 			layout: 'vbox',
 			style: {'padding':'15px', 'border-bottom':'1px #CBCAC7 solid'},
 			minHeight: 100,
 			items: [
 				{
					xtype: 'panel',
					style: 'margin-bottom:10px',
					html: "<p style='margin-left:5px'><font size='4'><b>Introduction</b></font></p>"
				},
				{
					xtype: 'dataview',
					id: 'otherintroview',
					scrollable: false,
					itemTpl:"&nbsp;<font size='3'>{Introduction}</font>"
				}
 			]
 		},
 		{
 			xtype: 'panel',
 			layout: 'hbox',
 			style: 'border-bottom:1px #CBCAC7 solid',
 			height: 135,
 			items:[{
 				xtype: 'panel',
 				flex:1,
 				layout: 'vbox',
 				style: 'margin-top:10px',
 				items: [{
 					xtype: 'panel',
 					docked: 'right',
 					items:[{
							xtype: 'panel',
		 					style: 'padding-top:10px;',
		 					items:[{
	 						xtype: 'image',
		 					width: 48,
		 					height: 48,
		 					src: 'resource/images/Meeting1.png'
	 					}]
	 				},
	 				{
	 					xtype: 'panel',
	 					width: 48,
	 					html: '<font size="2">&nbsp;You</font>'
 					}]
 				}]
 			},
 			{
 				xtype: 'panel',
 				flex:1.5,
 				layout: 'vbox',
 				style: 'margin-top:10px',
 				items: [{
 					xtype: 'panel',
					style: 'margin-left:10px;margin-top:10px',
					id: 'othertfigetdata',
					layout: 'hbox',
					flex:2,
					listeners: {
						tap: {
							element: 'element',
							fn: function() {
								var record = this.getData();
								
								var Tdetail = Ext.create('Triends.view.Tdetail2');
								var Tfidistance = Ext.getCmp('Tfidistance2');
								var Tfitime = Ext.getCmp('Tfitime2');
								var Tfitheme = Ext.getCmp('Tfitheme2');
								var distance = record.get("Distance").split(".")[0];
						    	var time = record.get("Time").split(".")[0];
						    	if (time < 60){
						    		Tfitime.setHtml("<font size='5'>"+time+"</font>분 전")
						    	}else if(time > 60 && time < 1440){
						    		time = time/60;
						    		time = Math.round(time);
						    		Tfitime.setHtml("<font size='5'>"+time+"</font>시간 전")
						    	}else if(time > 1440){
						    		time = time/1440;
						    		time = Math.round(time);
						    		Tfitime.setHtml("<font size='5'>"+time+"</font>일 전")
						    	}
						    	var theme = record.get("UserTheme");
						    	Tfidistance.setData({Distance: distance});
						    	Tfitheme.setHtml('<img src="resource/images/'+theme+'.png">');
						    	Ext.Viewport.add(Tdetail);
							}
						}
					},
					items: [{
						xtype: 'panel',
						layout: 'vbox',
						flex:1,
						style: 'padding-left:5px;',
						items: [{
							xtype: 'panel',
							docked: 'right',
							style: 'margin-right:3px',
							items: [{
								xtype: 'panel',
								width: '40px',
								height: '40px',
								id: 'otherinfotfipicture'
							},
							{
								xtype: 'panel',
								style: 'text-align:center; margin-top:-5px;',
								html: 'T-fi'
							}]
						}]
					},
					{
						xtype: 'panel',
						style: 'text-align:left;padding-top:18px;margin-left:3px;',
						id: 'othertfipanel',
						flex: 1
					}]
 				},
 				{
 					xtype: 'panel',
 					flex: 1,
 					style: 'text-align:center;margin-top:-50px',
 					html: '...................'
 				}]
 			},
 			{
 				xtype: 'panel',
 				flex:1,
 				style: 'margin-top:10px',
 				layout: 'vbox',
 				items: [{
 					xtype: 'panel',
 					docked: 'left',
 					style: 'margin-left:10px;',
 					items:[{
 						xtype: 'panel',
	 					style: 'padding-top:10px;',
	 					items:[{
	 						xtype: 'image',
		 					width: 48,
		 					height: 48,
		 					src: 'resource/images/Meeting2.png'
	 					}]
	 				},
	 				{
	 					xtype: 'panel',
	 					id: 'othertfinamepanel',
	 					style: 'margin-left:-10px;text-align:center;margin-top:5px',
	 					width: 80
 					}]
 				}]
 			}]
 		},
		{
				xtype: 'othertinglist'
		}]
	}
});

Ext.define('Triends.view.Tdetail2', {
	extend: 'Ext.Panel',
	xtype: 'Tdetail2',
	id: 'Tdetail2',
	config: {
    	modal: true,
    	top: '10%',
    	left: '50%',
    	layout: 'vbox',
    	style: 'margin-left:-150px',
		hideOnMaskTap: true,
		width: 300,
		height: 350,
		listeners: {
			hide: function() {
				this.destroy();
			}
		},
    	items: [{
    		xtype: 'titlebar',
    		docked: 'top',
    		title: '<div class="title"><font size="3">T-fi 구성요소</font></div>'
    	},
    	{
    		xtype: 'panel',
    		style: 'padding:10px',
    		layout: 'vbox',
    		items: [{
    			xtype: 'panel',
    			html: '<font size="3"><b>거리</b></font>'
    		},
    		{
    			xtype: 'panel',
    			id: 'Tfidistance2',
    			width: '100%',
    			style: 'margin-top:10px;text-align:center',
    			tpl: "<font size='5'>{Distance}</font> km"
    		},
    		{
    			xtype: 'panel',
    			style: 'margin-top:30px',
    			html: '<font size="3"><b>업데이트 시간</b></font>'
    		},
    		{
    			xtype: 'panel',
    			id: 'Tfitime2',
    			width: '100%',
    			style: 'margin-top:10px;text-align:center'
    		},
    		{
    			xtype: 'panel',
    			style: 'margin-top:30px',
    			html: '<font size="3"><b>Theme</b></font>'
    		},
    		{
    			xtype: 'panel',
    			width: '100%',
    			items:[{
    				xtype: 'panel',
		    		style: 'left:50%; margin-left:-24px',
	    			id: 'Tfitheme2',
	    			width: 48
    			}]
    		}]
    	}]
	}
});